﻿using System;
using System.Runtime.InteropServices;

namespace QuotationService.RealtimeQuotation
{
    /// <summary>
    /// 期权基本信息
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
    internal struct OptionBasicInfo
    {
        /// <summary>
        /// 商品代码
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.CodeLength)]
        public string Code;

        /// <summary>
        /// 商品名称
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.NameLength)]
        [ServiceManager.Utils.Encoding("UTF-8")]
        public string Name;

        /// <summary>
        /// 商品ID
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 9)]
        public string ProductId;

    
        /// <summary>
        /// 证券类别
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.StkTypeLength)]
        public string StkType;

        /// <summary>
        /// 交易类别
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.TradeTypeLength)]
        public string TradeType;

        /// <summary>
        /// 涨停价
        /// </summary>
        public double MaxOrderPrice;

        /// <summary>
        /// 跌停价
        /// </summary>
        public double MinOrderPrice;

        /// <summary>
        /// 开盘价
        /// </summary>
        public double OpenPrice;

        /// <summary>
        /// 收盘价
        /// </summary>
        public double PreClosePrice;

        /// <summary>
        /// 上市日期
        /// </summary>
        public Int32 BeginDate;

        /// <summary>
        /// 到期/交割日
        /// </summary>
        public Int32 EndDate;

        /// <summary>
        /// 交割日
        /// </summary>
        public Int32 AccountDate;

        /// <summary>
        /// 价格档位
        /// </summary>
        public double OrderPriceUnit;

        /// <summary>
        /// 小数位数
        /// </summary>
        public Int32 Decimal;

        /// <summary>
        /// 市场持仓量
        /// </summary>
        public Int64 OpenPosition;


        /// <summary>
        /// 昨日成交量
        /// </summary>
        public Int64 PreExchTotalKnockQty;

        /// <summary>
        /// 昨日成交金额
        /// </summary>
        public double PreExchTotalKnockAmt;

        /// <summary>
        /// 昨日持仓量
        /// </summary>
        public Int64 PreOpenPosition;

        /// <summary>
        /// 合约乘数
        /// </summary>
        public Int32 ContractTimes;

        /// <summary>
        /// 合约序号
        /// </summary>
        public Int32 ContractSerialNo;

        /// <summary>
        /// 昨日结算价
        /// </summary>
        public double PreSettlementPrice;

        /// <summary>
        /// 今日结算价
        /// </summary>
        public double SettlementPrice;

        /// <summary>
        /// 限价委托上限
        /// </summary>
        public Int32 MaxLimitOrderQty;

        /// <summary>
        /// 限价委托下限
        /// </summary>
        public Int32 MinLimitOrderQty;

        /// <summary>
        /// 市价委托上限
        /// </summary>
        public Int32 MaxMarketOrderQty;

        /// <summary>
        /// 市价委托下限
        /// </summary>
        public Int32 MinMarketOrderQty;


        /// <summary>
        /// 每手数量
        /// </summary>
        public int ConvertQty;

        /// <summary>
        /// 标的证券代码
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.CodeLength)]
        public string BasicStockId;

        /// <summary>
        /// 期权类型
        /// </summary>
        public char OptionType;

        /// <summary>
        /// 买权/卖权
        /// </summary>
        public char OptionCPFlag;

        /// <summary>
        /// 行权价格
        /// </summary>
        public double ExecPrice;

        /// <summary>
        /// 历史波动率
        /// </summary>
        public double HV;


        /// <summary>
        /// 静态资料版本，格式为：YYYYMMDDhhmmss，即：年月日时分秒
        /// </summary>
        public Int64 StaticVer;

        /// <summary>
        /// 动态资料版本，格式为：YYYYMMDDhhmmss，即：年月日时分秒
        /// </summary>
        public Int64 DynamicVer;

        /// <summary>
        ///记录更新的时间
        /// </summary>
        public DateTime UpdateTime;

        /// <summary>
        /// 行情记录中包含的行情时间
        /// </summary>
        public DateTime QuotationTime;
    }
}
